﻿
@{
    ViewData["Title"] = "设置网站的标题(后缀)";
    var config = ViewData["titleConfig"] as site_config;
    var user = ViewData["user"] as WqUser;
}

<div class="row">
    <form id="ajaxForm" enctype="multipart/form-data" class="form-horizontal">

        <div class="container-fluid">

            <div class="row form-group">
                <label class="control-label col-md-2">配置的key</label>
                <div class="col-md-10">
                    <input class="form-control" name="config_key" type="text" value="@ConfigKey.SiteTitle" readonly />
                </div>
            </div>
            <div class="row form-group">
                <label class="control-label col-md-2">分类标签</label>
                <div class="col-md-10">
                    <input class="form-control" name="config_category" type="text" asp-for="@config.config_category" placeholder="可空" />
                </div>
            </div>
            <div class="row form-group">
                <label class="control-label col-md-2">描述</label>
                <div class="col-md-10">
                    <input class="form-control" name="description" type="text" asp-for="@config.description" placeholder="备注内容,可空" />
                </div>
            </div>
            <div class="row form-group">
                <label class="control-label col-md-2">网站标题</label>
                <div class="col-md-10">
                    <input class="form-control" name="config_value" id="config_value" type="text" asp-for="@config.config_value" />
                    <div class="text text-info">谨慎修改,搜索引擎会收录网站的标题作为关键字,只需要在网站初始化修改一次即可</div>
                </div>
            </div>
            <div class="row form-group">
                <label class="control-label col-md-2">修改人</label>
                <div class="col-md-10" title="@user.UserName" data-uid="@user.Id">
                    <input class="form-control" name="NickName" type="text" value="@user.NickName" readonly />
                </div>
            </div>
            <div class="row form-group">
                <label class="control-label col-md-2">创建时间</label>
                <div class="col-md-10">
                    <input class="form-control" name="create_time" id="create_time" type="text" value="@config.create_time.ToLocalDateTimeString()" disabled />
                </div>
            </div>
            <div class="row form-group">
                <label class="control-label col-md-2">更新时间</label>
                <div class="col-md-10">
                    <input class="form-control" name="last_update" id="last_update" type="text" value="@config.last_update.ToLocalDateTimeString()" disabled />
                </div>
            </div>
            <div class="row form-group">
                <div class="col-md-6 col-md-offset-2">
                    <button type="button" class="btn btn-primary ladda-button btn-save">保存</button>
                </div>
            </div>
        </div>
    </form>
</div>

@section scripts{

    <script type="text/javascript">

        $(".btn-save").click(function () {
            if ($("#config_value").val().length === 0) {
                utils.ShowError("请输入网站标题");
                return;
            }

            $("#ajaxForm").ajaxSubmit({
                type: 'post',
                url: '@Url.Action("UpdateSiteTitle")',
                data: {

                },  // data是作为额外提交的表单数据
                success: function (e) {
                    if (e.msg == 'ok') {
                        utils.ShowSuccess(e.data, function () {
                            location.reload(true);
                        });
                    }
                },
                error: function (e) {
                    utils.ShowError(e.data);
                }
            });
        });
    </script>
}

